RAIS  3.2
C:/Projekte/RAIS/Specific Masks/SpecificReportFieldMapping.aspx.cs
Go to the documentation of this file.
00001 
00027 using System;
00028 using System.Data;
00029 using System.Configuration;
00030 using System.Collections;
00031 using System.Web;
00032 using System.Web.Security;
00033 using System.Web.UI;
00034 using System.Web.UI.WebControls;
00035 using System.Web.UI.WebControls.WebParts;
00036 using System.Web.UI.HtmlControls;
00037 using RAIS.Common.UserManagement;
00038 using RAIS.Common;
00039 using RAIS.UI.Common;
00040 using System.Collections.Generic;
00041 
00042 namespace RAIS.UI.SpecificMasks
00043 {
00047     public partial class SpecificReportFieldMapping : System.Web.UI.Page
00048     {
00049         //*********************************************************************
00050 
00051         #region FIELDS
00052         private SpecificReport report;
00053         #endregion
00054 
00055         #region PROPERTIES
00056 
00059         protected UserData CurrentUser
00060         {
00061             get { return (UserData)this.Session[UI.Common.Constants.CURRENT_USER_TAG]; }
00062         }
00063         protected SpecificReport.SpecificReportFieldType SelectedFieldType
00064         {
00065             get
00066             {
00067                 return report.GetFieldTypeFromString(LBXreportFields.SelectedValue.Substring(LBXreportFields.SelectedValue.IndexOf(':') + 1));
00068             }
00069         }
00070         protected string SelectedReportField
00071         {
00072             get
00073             {
00074                 return LBXreportFields.SelectedItem.Text;
00075             }
00076         }
00077         #endregion
00078 
00079         #region EVENTS
00080         protected void Page_PreLoad(object sender, EventArgs e)
00081         {
00082             RAIS.UI.Common.PageManagement.TrimTextBoxValues(this);
00083         }
00084 
00085         protected void Page_Load(object sender, EventArgs e)
00086         {
00087             this.Response.Cache.SetNoStore();
00088             if (this.CurrentUser == null)
00089                 UI.Common.AccessManagement.SignOut(this);
00090 
00091             if (!IsPostBack)
00092             {
00093                 this.LBLusernameNoTranslation.Text = this.CurrentUser.Name;
00094                 UI.Common.PageManagement.InitializePageTreeForCategory(this, this.TreeView1, RAIS.Common.Constants.CATEGORY_NAME_ADMINISTRATION);
00095                 this.LBLadmin.ForeColor = RAIS.UI.Common.Constants.COLOR_OF_MENU_BAR_TEXT_HIGHLIGHT;
00096 
00097                 if (Session["SelectedSpecificReportID"] != null)
00098                 {
00099                     int reportID = (int)Session["SelectedSpecificReportID"];
00100                     string reportDefinition = SpecificReportManagement.GetSpecificReportDefinition(reportID);
00101                     report = new SpecificReport(reportID, reportDefinition);
00102                     TBXreport.Text = SpecificReportManagement.GetSpecificReportNameById(reportID);
00103                     Session["SelectedSpecificReport"] = report;
00104                     foreach (KeyValuePair<string, SpecificReport.SpecificReportFieldType> pair in report._ReportFields)
00105                     {
00106                         LBXreportFields.Items.Add(new ListItem(pair.Key, pair.Key + ":" + pair.Value));
00107                     }
00108 
00109                     // Initialize mask fields
00110                     foreach (string field in SpecificReportManagement.GetQueryFieldsByID(reportID))
00111                     {
00112                         DDLmaskFields.Items.Add(field);
00113                     }
00114 
00115                     // Initialize reports
00116                     foreach (KeyValuePair<string, string> pair in SpecificReportManagement.GetReports())
00117                     {
00118                         if (SpecificReportManagement.GetSubreports(Convert.ToInt32(pair.Key)).Count == 0 && this.report.SpecificReportID != int.Parse(pair.Key))
00119                             DDLreports.Items.Add(new ListItem(pair.Value, pair.Key));
00120                     }
00121                 }
00122             }
00123             else
00124             {
00125                 report = (SpecificReport)Session["SelectedSpecificReport"];
00126             }
00127 
00128             UI.Common.Localisation.TranslatePage(this);
00129             UI.Common.PageManagement.InitHelpMainMenu(LBTNdefault);
00130         }
00131 
00132         protected void Page_Init(object sender, EventArgs e)
00133         {
00134             PageManagement.SetScrolableListBox(this.LBXreportFields, this, true);
00135         }
00136 
00137         protected void LNKspecificReports_Click(object sender, EventArgs e)
00138         {
00139             this.Response.Redirect("~/SpecificReports.aspx");
00140         }
00141 
00142         protected void BTNapply_Click(object sender, EventArgs e)
00143         {
00144             if (LBXreportFields.SelectedItem != null)
00145             {
00146                 switch (this.SelectedFieldType)
00147                 {
00148                     case SpecificReport.SpecificReportFieldType.Textbox:
00149                         if (!CBXpageBreak.Visible)
00150                             SpecificReportManagement.SaveReportDefinition(report.SpecificReportID, report.GetFieldConnection(SelectedReportField, DDLmaskFields.SelectedItem.Text));
00151                         else
00152                             SpecificReportManagement.SaveReportDefinition(report.SpecificReportID, report.GetFieldConnection(SelectedReportField, DDLmaskFields.SelectedItem.Text, CBXpageBreak.Checked));
00153                         break;
00154                     case SpecificReport.SpecificReportFieldType.List:
00155                         SpecificReportManagement.SaveReportDefinition(report.SpecificReportID, report.GetListConnection(SelectedReportField, DDLmaskFields.SelectedItem.Text, CBXpageBreak.Checked));
00156                         break;
00157                     case SpecificReport.SpecificReportFieldType.Table:
00158                         SpecificReportManagement.SaveReportDefinition(report.SpecificReportID, report.GetTableConnection(SelectedReportField, DDLmaskFields.SelectedItem.Text, CBXpageBreak.Checked));
00159                         break;
00160                     case SpecificReport.SpecificReportFieldType.Subreport:
00161                         SpecificReportManagement.SaveReportDefinition(report.SpecificReportID, report.GetSubreportConnection(SelectedReportField, DDLreports.SelectedItem.Text));
00162                         break;
00163                 }
00164             }
00165             LBXreportFields.Enabled = true;
00166             DDLmaskFields.Enabled = false;
00167             BTNundo.Enabled = false;
00168             BTNapply.Enabled = false;
00169             BTNedit.Enabled = true;
00170             CBXpageBreak.Enabled = false;
00171             LNKspecificReports.Enabled = true;
00172             DDLreports.Enabled = false;
00173             DDLmaskFields.Enabled = false;
00174         }
00175 
00176         protected void BTNedit_Click(object sender, EventArgs e)
00177         {
00178             LBXreportFields.Enabled = false;
00179             DDLmaskFields.Enabled = true;
00180             BTNundo.Enabled = true;
00181             BTNapply.Enabled = true;
00182             BTNedit.Enabled = false;
00183             CBXpageBreak.Enabled = true;
00184             LNKspecificReports.Enabled = false;
00185             DDLreports.Enabled = true;
00186             DDLmaskFields.Enabled = true;
00187         }
00188 
00189         protected void BTNundo_Click(object sender, EventArgs e)
00190         {
00191             LBXreportFields.Enabled = true;
00192             DDLmaskFields.Enabled = false;
00193             BTNundo.Enabled = false;
00194             BTNapply.Enabled = false;
00195             BTNedit.Enabled = true;
00196             CBXpageBreak.Enabled = false;
00197             LNKspecificReports.Enabled = true;
00198             DDLreports.Enabled = false;
00199             DDLmaskFields.Enabled = false;
00200         }
00201 
00202         protected void LBXreportFields_SelectedIndexChanged(object sender, EventArgs e)
00203         {
00204             if (LBXreportFields.SelectedItem != null)
00205             {
00206                 bool cbxChecked = false;
00207                 TBXfieldType.Text = SelectedFieldType.ToString();
00208                 if (SelectedFieldType == SpecificReport.SpecificReportFieldType.Textbox)
00209                 {
00210                     string connectedField = report.GetConnectedDataField(this.SelectedReportField, this.SelectedFieldType, ref cbxChecked);
00211                     if (connectedField != null)
00212                         DDLmaskFields.SelectedIndex = DDLmaskFields.Items.IndexOf(DDLmaskFields.Items.FindByText(connectedField));
00213                     else
00214                         DDLmaskFields.SelectedIndex = 0;
00215 
00216                     LBLconnectedField.Text = "Connected field: ";
00217                     LBLconnectedField.ForeColor = System.Drawing.ColorTranslator.FromHtml("#496ABC");
00218                     bool isPartOfTable = report.IsPartOfTable(SelectedReportField);
00219                     if (isPartOfTable)
00220                         CBXpageBreak.Text = "Use current row for table grouping";
00221                     CBXpageBreak.Visible = isPartOfTable;
00222                     CBXpageBreak.Checked = cbxChecked;
00223                     LBLtableGrouping.Visible = isPartOfTable;
00224                     DDLreports.Visible = false;
00225                     DDLmaskFields.Visible = true;
00226                 }
00227                 else if (SelectedFieldType == SpecificReport.SpecificReportFieldType.List)
00228                 {
00229                     string connectedField = report.GetConnectedDataField(this.SelectedReportField, this.SelectedFieldType, ref cbxChecked);
00230                     if (connectedField != null)
00231                         DDLmaskFields.SelectedIndex = DDLmaskFields.Items.IndexOf(DDLmaskFields.Items.FindByText(connectedField));
00232                     else
00233                         DDLmaskFields.SelectedIndex = 0;
00234 
00235                     CBXpageBreak.Checked = cbxChecked;
00236                     LBLconnectedField.Text = "Group by: ";
00237                     LBLconnectedField.ForeColor = System.Drawing.Color.Red;
00238                     CBXpageBreak.Visible = true;
00239                     CBXpageBreak.Text = "Page break at end";
00240                     LBLtableGrouping.Visible = false;
00241                     DDLreports.Visible = false;
00242                     DDLmaskFields.Visible = true;
00243                 }
00244                 else if (SelectedFieldType == SpecificReport.SpecificReportFieldType.Table)
00245                 {
00246                     string connectedField = report.GetConnectedDataField(this.SelectedReportField, this.SelectedFieldType, ref cbxChecked);
00247                     if (connectedField != null)
00248                         DDLmaskFields.SelectedIndex = DDLmaskFields.Items.IndexOf(DDLmaskFields.Items.FindByText(connectedField));
00249                     else
00250                         DDLmaskFields.SelectedIndex = 0;
00251 
00252                     LBLconnectedField.Text = "Group by: ";
00253                     LBLconnectedField.ForeColor = System.Drawing.ColorTranslator.FromHtml("#496ABC");
00254                     CBXpageBreak.Visible = true;
00255                     CBXpageBreak.Checked = cbxChecked;
00256                     CBXpageBreak.Text = "Page break at end";
00257                     LBLtableGrouping.Visible = false;
00258                     DDLreports.Visible = false;
00259                     DDLmaskFields.Visible = true;
00260                 }
00261                 else if (SelectedFieldType == SpecificReport.SpecificReportFieldType.Subreport)
00262                 {
00263                     string connectedReport = report.GetConnectedDataField(SelectedReportField, SelectedFieldType, ref cbxChecked);
00264                     if (connectedReport != null)
00265                         DDLreports.SelectedIndex = DDLreports.Items.IndexOf(DDLreports.Items.FindByText(connectedReport));
00266                     else
00267                         DDLreports.SelectedIndex = 0;
00268 
00269                     LBLconnectedField.Text = "Connected report: ";
00270                     LBLconnectedField.ForeColor = System.Drawing.Color.Red;
00271                     CBXpageBreak.Visible = false;
00272                     LBLtableGrouping.Visible = false;
00273                     DDLreports.Visible = true;
00274                     DDLmaskFields.Visible = false;
00275                 }
00276                 BTNedit.Enabled = true;
00277                 TBXfieldName.Text = LBXreportFields.SelectedItem.Text;
00278             }
00279         }
00280 
00286         protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
00287         {
00288             UI.Common.UserManagement.ProcessTreeViewOnRedirect(this.TreeView1);
00289         }
00290 
00296         protected void LBTNlogout_Click(object sender, EventArgs e)
00297         {
00298             UI.Common.AccessManagement.SignOut(this);
00299         }
00300         #endregion
00301     }
00302 }